[deps]
kernel-headers
gnu-efi-libs
mtools

[deps.host]
perl
nasm

[vars]
filesize=9772883
sha512=ca3da9d7f5f1c4ccc2eaa1cc33f5d2bb4afe2518dadeb863169ba2cce023c62112e5312181b047ce868a217e36f9b103622cf2e0e8559c3b7de35ad191388450

[mirrors]
ftp://www.kernel.org/pub/linux/utils/boot/syslinux/syslinux-6.02.tar.bz2
http://www.kernel.org/pub/linux/utils/boot/syslinux/syslinux-6.02.tar.bz2
http://www.kernel.org/pub/linux/utils/boot/syslinux/6.xx/syslinux-6.02.tar.bz2
http://ftp.wh2.tu-dresden.de/pub/mirrors/kernel.org/linux/utils/boot/syslinux/syslinux-6.02.tar.bz2
http://ftp.hosteurope.de/mirror/ftp.kernel.org/pub/linux/utils/boot/syslinux/syslinux-6.02.tar.bz2
http://ftp.uni-ulm.de/pub/mirrors/kernel.org/utils/boot/syslinux/6.xx/syslinux-6.02.tar.bz2

[build]

[ "$A" = "i386" ] || \
  [ "$A" = "x86_64" ] || ( \
    echo "WARNING: syslinux6 only supports the pc architecture"
    exit 0
  )
sed -i 's,codepage com32 lzo core memdisk mbr memdump gpxe sample,codepage com32 core mbr,g' Makefile
sed -i 's,diag libinstaller dos win32 win64 dosutil txt,libinstaller txt,g' Makefile
sed -i 's,win32/syslinux.exe win64/syslinux64.exe,,g' Makefile
sed -i 's,dosutil/*.com dosutil/*.sys,,g' Makefile
sed -i 's,gpxe/gpxelinux.0 dos/syslinux.com,,g' Makefile
sed -i 's,core/isolinux.bin core/isolinux-debug.bin,,g' Makefile
sed -i 's,core/pxelinux.0 core/lpxelinux.0,,g' Makefile
sed -i 's,codepage com32 lzo core mbr sample efi txt,codepage com32 core mbr efi txt,g' Makefile
sed -i 's,com32 utils dosutil,com32 utils,g' Makefile
sed -i 's,libupload tools lib elflink/ldlinux gpllib libutil modules mboot,lib libutil,' com32/Makefile
sed -i 's,menu samples elflink rosh cmenu hdt gfxboot sysdump lua/src chain,menu,' com32/Makefile
sed -i 's,#include <getkey.h>,#include "include/getkey.h",' com32/libutil/keyname.c
sed -i 's,#include <libutil.h>,#include "include/libutil.h",' com32/libutil/keyname.c
sed -i 's,#include "sha1.h",#include "include/sha1.h",' com32/libutil/sha1hash.c
sed -i 's,#include <base64.h>,#include "include/base64.h",' com32/libutil/unbase64.c
sed -i 's,#include <md5.h>,#include "include/md5.h",' com32/libutil/md5.c
sed -i 's,#include <md5.h>,#include "include/md5.h",' com32/libutil/crypt-md5.c
sed -i 's,#include <minmax.h>,#include "include/minmax.h",' com32/libutil/sha256crypt.c
sed -i 's,#include "xcrypt.h",#include "include/xcrypt.h",' com32/libutil/sha256crypt.c
sed -i 's,#include <minmax.h>,#include "include/minmax.h",' com32/libutil/sha512crypt.c
sed -i 's,#include "xcrypt.h",#include "include/xcrypt.h",' com32/libutil/sha512crypt.c
sed -i 's,#include <base64.h>,#include "include/base64.h",' com32/libutil/base64.c
sed -i '/herror.*/d' utils/gethostip.c
sed -ri 's,__uint([0-9]+)_t,uint\1_t,g' efi/wrapper.c
sed -ri 's,__uint([0-9]+)_t,uint\1_t,g' efi/wrapper.h

PREFIXED_PATHS="BINDIR='/bin' LIBDIR='/lib' DATADIR='/share' MANDIR='/man' INCDIR='/include'"

make $PREFIXED_PATHS AUXDIR="$butch_prefix/lib/syslinux/bios" INSTALLROOT="$butch_install_dir" bios installer
make $PREFIXED_PATHS AUXDIR="$butch_prefix/lib/syslinux/bios" INSTALLROOT="$butch_install_dir" -j1 bios install

if [ "$A" == "i386" ]; then
  make $PREFIXED_PATHS AUXDIR="$butch_prefix/lib/syslinux" INSTALLROOT="$butch_install_dir" efi32 installer
  make $PREFIXED_PATHS AUXDIR="$butch_prefix/lib/syslinux" INSTALLROOT="$butch_install_dir" -j1 efi32 install
elif [ "$A" == "x86_64" ]; then
  make $PREFIXED_PATHS AUXDIR="$butch_prefix/lib/syslinux" INSTALLROOT="$butch_install_dir" efi64 installer
  make $PREFIXED_PATHS AUXDIR="$butch_prefix/lib/syslinux" INSTALLROOT="$butch_install_dir" -j1 efi64 install
fi
